#ifndef VIEWWINDOW_H_H_H_H_
#define VIEWWINDOW_H_H_H_H_

#include <QMainWindow>
#include "BaseClass.h"
class Document_Gui;
class Document_App;

class BaseView : public Base::BaseClass
{
	TYPESYSTEM_HEADER();
public:

	BaseView(Document_Gui* pcDocument = 0);
	virtual ~BaseView();

	void setDocument(Document_Gui* pcDocument);
	void onClose(void);

	Document_Gui* getGuiDocument()const {return _pcDocument;}
	Document_App* getAppDocument()const;

	bool isPassive(void){return isbPassive;}

	virtual void onUpdate(void){}
	virtual void OnRelabel(Document_Gui*){}
	virtual void onRename(Document_Gui*){}

	virtual const char* getName()const {return "Base view";}

	virtual bool onMsg(const char* pMsg,const char** prReturn) = 0;
	virtual bool onHasMsg(const char* pMsg)const = 0;

	virtual bool canClose(void){return true;}

	virtual void deleteSelf();

protected:
	Document_Gui* _pcDocument;
	bool isbPassive;
	bool bIsDetached;
};
class ViewWindow : public QMainWindow, public BaseView
{
	Q_OBJECT;

	TYPESYSTEM_HEADER();
public:
	ViewWindow(Document_Gui* pcDocument,QWidget* parent,Qt::WFlags wflags = 0);
	~ViewWindow(void);

public:
	virtual bool onMsg(const char* pMsg,const char** ppReturn);
	/// Message handler test
	virtual bool onHasMsg(const char* pMsg) const;

	virtual bool canClose(void);

	virtual void deleteSelf();

	Document_Gui* getGuiDocument()const;

	void resizeEvent(QResizeEvent * e);



public Q_SLOTS:
		virtual void setOverrideCursor(const QCursor&);
		virtual void restoreOverrideCursor();
		virtual void print(QPrinter* printer);


public:

	enum ViewMode
	{
		Child,
		TopLevel,
		FullScreen
	};

	virtual void setCurrentViewMode(ViewMode mode);
	ViewMode currentViewMode()const {return currentMode;}

Q_SIGNALS:
	void message(const QString&,int);

protected Q_SLOTS:

	virtual void windowStateChanged(ViewWindow*);

protected:
	void closeEvent(QCloseEvent * e);
	void changeEvent(QEvent * e);

private:
	ViewMode currentMode;
	Qt::WindowStates wstate;

};
#endif